#include "View/CurveView.hpp"
#include "Graphics/Vertex.hpp"
#ifdef DEBUG
#include <iostream>
#endif

using Graph::Vertex;
using Graph::VertexVector;

CurveView::CurveView(Graphics *gs, CurveData *data)
    : View(gs)
{
    m_data = data;
}

void CurveView::update()
{
    this->draw();
}

void CurveView::draw()
{
#ifdef DEBUG
    std::cout << "CurveView::draw()\n";
    std::cout << "size = " << m_data->getPoints().size() <<  std::endl;
#endif
    uint32_t blackColor = m_gs->intColor(0, 0, 0, 255);
    VertexVector v;

#if defined(_MSC_VER) && _MSC_VER <= 1600
	for (auto point = m_data->getPoints().begin(); point != m_data->getPoints().end(); ++point)
    {
        Vertex vertex((*point)->x(), (*point)->y(), 0.0f, blackColor);
        v.push_back(vertex);
    }
#else
	for (auto point : m_data->getPoints())
    {
        Vertex vertex(point->x(), point->y(), 0.0f, blackColor);
        v.push_back(vertex);
    }
#endif

    m_gs->drawPolyLine(v);
}

void CurveView::bounds(double &x1, double &y1, double &x2, double &y2)
{
}


bool CurveView::intersects(const double x, const double y)
{
    return true;
}

CurveView::~CurveView()
{
}
